/**
 * Created by lvlq on 16/2/27.
 */
var urllib = require("urllib");
var Q = require("q");

var checkAcCode = function (ip, acCode) {
    var defer = Q.defer();
    var url = "http://shellrev.weixinzjit.com/index/wsdl/getaccode";
    urllib.request(url, {
        method: "POST",
        data: {
            ip: ip,
            acCode: acCode
        }
    }, function (err, data) {
        if (err) defer.reject(err);
        else {
            defer.resolve(JSON.parse(data.toString()));
        }
    });

    return defer.promise;
};

module.exports = {
    checkAcCode: checkAcCode
};